package com.mlz.mlzmall.ui.dialog;

import android.Manifest;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import com.mlz.mlzmall.R;
import com.mlz.mlzmall.ui.utils.util.ScreenUtils;


/**
 * 弹窗
 */
public class ReuestDialog {
    public static ProgressDialog progDialog;
    private static View pw;
    private static PopupWindow pWindow;

    // 显示进度 ?
    public static void showProgressDialog(Context context) {
        if (progDialog == null) {
            progDialog = new ProgressDialog(context);
            progDialog.setCanceledOnTouchOutside(false);
            progDialog.setMessage("正在加载..");
            progDialog.show();
        } else if (!progDialog.isShowing())
            progDialog.show();
     //  showPopwindows(context);
    }

    private static void showPopwindows(Context context) {
//  退出对话框
        pw = LayoutInflater.from(context).inflate(R.layout.reust_layout, null);
        pWindow = new PopupWindow(pw, ScreenUtils.getScreenWidth(context)*3/5,ScreenUtils.getScreenWidth(context)*3/5);//弹框显示大小
        pWindow.setFocusable(true);
        pWindow.setBackgroundDrawable(new ColorDrawable(0x55000000));//设置背景为透明
        pWindow.setAnimationStyle(R.style.AnimationCenter);
        pWindow.showAtLocation(pw, Gravity.CENTER, 0, 0);

    }

    // 隐藏进度 ?
    public static void dissmissProgressDialog() {
    //    pWindow.dismiss();
        if (progDialog != null) {
            progDialog.dismiss();
            progDialog = null;
        }
    }

}
